﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BusinessHanler;

namespace BusinessHandler
{
    public class AccountController : NewsDataClassesDataContext
    {
        private static AccountController instance;
        public static AccountController Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new AccountController();
                }
                return instance;
            }
            set
            {
                instance = value;
            }
        }
        public List<AccountUser> GetList(AccountUser condition, int skip, int take, ref int total)
        {
            NewsDataClassesDataContext dataContext = new NewsDataClassesDataContext();
            var list = (from o in dataContext.AccountUsers
                        where (condition.AccountUserName == null || o.AccountUserName.Contains(condition.AccountUserName)) &&
                        (condition.AccountSignDate == null || o.AccountSignDate == condition.AccountSignDate) &&
                        (condition.AccountLastLoginTime == null || o.AccountLastLoginTime == condition.AccountLastLoginTime) &&
                        (condition.AccountBanned == null || o.AccountBanned == condition.AccountBanned) &&
                        (condition.AccountBannedOn == null || o.AccountBannedOn == condition.AccountBannedOn) &&
                        (condition.AccountBannedBy == null || o.AccountBannedBy == condition.AccountBannedBy) &&
                        (condition.AccountBanPeriod == null || o.AccountBanPeriod == condition.AccountBanPeriod) &&
                        (condition.AccountUserStatus == null || o.AccountUserStatus == condition.AccountUserStatus)
                        select o);
            total = list.Count();
            return (list.Skip(skip).Take(take).ToList());
        }
    }
}